package com.whf.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.whf.dataobject.OrderDetail;
import com.whf.enums.OrdersStatusEnum;
import com.whf.enums.PayStatusEnum;
import com.whf.utils.EnumUtil;
import com.whf.utils.KeyUtil;
import com.whf.utils.ResultVOUtil;
import com.whf.utils.serializer.Data2LongSerizlizer;
import lombok.Data;

import javax.persistence.Id;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018/7/13 0013.
 */
@Data
//该注解可以将实体类中的null的属性自动忽略
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO implements Serializable{

    private static final long serialVersionUID = 7579647292741155971L;
    //订单id
    private String orderId;
    //买家姓名
    private String buyerName;
    //买家电话
    private String buyerPhone;
    //买家地址
    private String buyerAddress;
    //买家微信地址
    private String buyerOpenid;
    //订单金额
    private BigDecimal orderAmount;
    //订单状态,默认为0,新下单
    private Integer orderStatus;
    //付款状态,默认为0,未支付
    private Integer payStatus;
    //创建时间
    @JsonSerialize(using = Data2LongSerizlizer.class )
    private Date createTime;
    //更新时间
    @JsonSerialize(using = Data2LongSerizlizer.class )
    private Date updateTime;
    private List<OrderDetail> orderDetailList;

    //该注解可以在返回json格式时自动忽略该字段
    @JsonIgnore
    public OrdersStatusEnum getOrderStausEnum(){
        return EnumUtil.getByCode(this.orderStatus, OrdersStatusEnum.class);
    }
    @JsonIgnore
    public PayStatusEnum getPayStausEnum(){
        return EnumUtil.getByCode(this.payStatus, PayStatusEnum.class);
    }
}
